#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > walk_gradex.info <<'%EOF%'
   walk_gradex
   -----------
   Molecule:         NH3
   Wave Function:    SCF / 6-31G** (Atombasis)
   Test Purpose:     Locating a transition state following a gradient
                     extremal
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > walk_gradex.mol <<'%EOF%'
ATOMBASIS
Location of saddle point (transition state) by following
a gradient extremal
Cartesian Atomtypes=2 Nosymmetry
Charge=7.0 Atoms=1      Basis=6-31G**
N          -.2402098951            -.0000003109             .5147128871
Charge=1.0 Atoms=3      Basis=6-31G**
H          1.4837091636             .0000000802            -.2633317998
H         -1.1558499044            1.5260201343            -.1256905028
H         -1.1558492311           -1.5260211423            -.1256905447
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > walk_gradex.dal <<'%EOF%'
**DALTON INPUT
.WALK
*WALK
.GRDEXT
.INDEX
  1
.MODE
 1
**WAVE FUNCTION
.HF
*SCF INPUT
.THRESH
1.0d-6
**PROPERTIES
.VIBANA
.POPANA
**END OF DALTON INPUT
%EOF%
#######################################################################



#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >walk_gradex.check
cat >>walk_gradex.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a -l"
else
   GREP="egrep -l"
fi

# WALK module
CRIT1=`$GREP "Commencing geometry optimization based on \.WALK" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=1
ERROR[1]="WALK MODULE NOT USED"

# Atombasis
CRIT1=`$GREP "N * 1 * 7\.0000 * 28 * 15 * \[10s4p1d\|3s2p1d\]" $log | wc -l`
CRIT2=`$GREP "H * 3 * 1\.0000 * 7 * 5 * \[4s1p\|2s1p\]" $log | wc -l`
CRIT3=`$GREP "total\: * 4 * 10\.0000 * 49 * 30" $log | wc -l`
TEST[2]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[2]=3
ERROR[2]="ATOMBASIS NOT READ CORRECTLY"

# Cartesian functions
CRIT1=`$GREP "Cartesian basis used" $log | wc -l`
TEST[3]=`expr	$CRIT1`
CTRL[3]=1
ERROR[3]="CARTESIAN BASIS FUNCTIONS NOT USED"

# Geometry
CRIT1=`$GREP "Total number of coordinates\: * 12" $log | wc -l`
CRIT2=`$GREP "1 * x * (\-0|\-)\.2402098951" $log | wc -l`
CRIT3=`$GREP "2 * y * (\-0|\-)\.0000003109" $log | wc -l`
CRIT4=`$GREP "3 * z * (0| )\.5147128871" $log | wc -l`
CRIT5=`$GREP "4 * x * 1\.4837091636" $log | wc -l`
CRIT6=`$GREP "5 * y * (0| )\.0000000802" $log | wc -l`
CRIT7=`$GREP "6 * z * (\-0|\-)\.2633317998" $log | wc -l`
CRIT8=`$GREP "7 * x * \-1\.1558499044" $log | wc -l`
CRIT9=`$GREP "8 * y * 1\.5260201343" $log | wc -l`
CRIT10=`$GREP "9 * z * (\-0|\-)\.1256905028" $log | wc -l`
CRIT11=`$GREP "10 * x * \-1\.1558492311" $log | wc -l`
CRIT12=`$GREP "11 * y * \-1\.5260211423" $log | wc -l`
CRIT13=`$GREP "12 * z * (\-0|\-)\.1256905447" $log | wc -l`
TEST[4]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13`
CTRL[4]=13
ERROR[4]="MOLECULAR GEOMETRY NOT READ CORRECTLY"

# Initial energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.1955447526(3|4)[0-9]" $log | wc -l`
TEST[5]=`expr	$CRIT1`
CTRL[5]=1
ERROR[5]="INITIAL ENERGY NOT CORRECT"

# Optimization setup
CRIT1=`$GREP "Walk type\: Gradient\-extremal walk" $log | wc -l`
CRIT2=`$GREP "Index of critical point searched\: 1" $log | wc -l`
CRIT3=`$GREP "Hessian mode selection \: * 1" $log | wc -l`
TEST[6]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[6]=3
ERROR[6]="GEOMETRY OPTIMIZATION NOT SET UP CORRECTLY"

# Initial gradient
# Norm of molecular gradient:     0.0000019026
CRIT1=`$GREP "Norm of molecular gradient: * 0*\.00000[12]" $log | wc -l`
TEST[7]=`expr	$CRIT1 `
CTRL[7]=1
ERROR[7]="INITIAL GRADIENT NOT CORRECT"

# Initial Hessian
CRIT1=`$GREP "N * x * (0| )\.74534[0-9]" $log | wc -l`
CRIT2=`$GREP "N * y * (\-0|\-|0| )\.00000. * (0| )\.74669[0-9]" $log | wc -l`
CRIT3=`$GREP "N * z * (\-0|\-)\.02598[0-9] * (\-0|\-|0| )\.000000 * (0| )\.24846[0-9]" $log | wc -l`
CRIT4=`$GREP "H * x * (\-0|\-)\.40635[0-9] * (\-0|\-|0| )\.00000[0-9] * (0| )\.14932[0-9] * (0| )\.4436(3|4)[0-9]" $log | wc -l`
CRIT5=`$GREP "H * y * (\-0|\-|0| )\.00000. * (\-0|\-)\.07353[0-9] * (\-0|\-|0| )\.000000 * (0| )\.00000[0-9] * (0| )\.06926[0-9]" $log | wc -l`
CRIT6=`$GREP "H * z * (0| )\.21103[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.10028[0-9] * (\-0|\-)\.17352[0-9] * (\-0|\-|0| )\.000000 * (0| )\.09503[0-9]" $log | wc -l`
CRIT7=`$GREP "H * x * (\-0|\-)\.16949[0-9] * (0| )\.16042[0-9] * (\-0|\-)\.06167[0-9] * (\-0|\-)\.0186(3|4)[0-9] * (0| )\.0378(3|4)[0-9] * (\-0|\-)\.01875[0-9]" $log | wc -l`
CRIT8=`$GREP "H * y * (0| )\.15763[0-9] * (\-0|\-)\.33658[0-9] * (0| )\.10662[0-9] * (\-0|\-)\.00339[0-9] * (0| )\.00213[0-9] * (0| )\.00143[0-9]" $log | wc -l`
CRIT9=`$GREP "H * z * (\-0|\-)\.09252[0-9] * (0| )\.15999[0-9] * (\-0|\-)\.07409[0-9] * (0| )\.01209[0-9] * (\-0|\-)\.01855[0-9] * (0| )\.00262[0-9]" $log | wc -l`
CRIT10=`$GREP "H * x * (\-0|\-)\.16949[0-9] * (\-0|\-)\.16042[0-9] * (\-0|\-)\.06167[0-9] * (\-0|\-)\.01864[0-9] * (\-0|\-)\.03784[0-9] * (\-0|\-)\.01875[0-9]" $log | wc -l`
CRIT11=`$GREP "H * y * (\-0|\-)\.15763[0-9] * (\-0|\-)\.33658[0-9] * (\-0|\-)\.10662[0-9] * (0| )\.00339[0-9] * (0| )\.00213[0-9] * (\-0|\-)\.00143[0-9]" $log | wc -l`
CRIT12=`$GREP "H * z * (\-0|\-)\.09252[0-9] * (\-0|\-)\.15999[0-9] * (\-0|\-)\.07409[0-9] * (0| )\.01209[0-9] * (0| )\.01855[0-9] * (0| )\.00262[0-9]" $log | wc -l`
CRIT13=`$GREP "H * x * (0| )\.1749(1|2)[0-9]" $log | wc -l`
CRIT14=`$GREP "H * y * (\-0|\-)\.17625[0-9] * (0| )\.36287[0-9]" $log | wc -l`
CRIT15=`$GREP "H * z * (0| )\.07216[0-9] * (\-0|\-)\.12475[0-9] * (0| )\.07014[0-9]" $log | wc -l`
CRIT16=`$GREP "H * x * (0| )\.01321[0-9] * (0| )\.02201[0-9] * (0| )\.00826[0-9] * (0| )\.17492[0-9]" $log | wc -l`
CRIT17=`$GREP "H * y * (\-0|\-)\.0220(0|1)[0-9] * (\-0|\-)\.02843[0-9] * (\-0|\-)\.01669[0-9] * (0| )\.17625[0-9] * (0| )\.36287[0-9]" $log | wc -l`
CRIT18=`$GREP "H * z * (0| )\.0082(5|6)[0-9] * (0| )\.01669[0-9] * (0| )\.00132[0-9] * (0| )\.07216[0-9] * (0| )\.12475[0-9] * (0| )\.07014[0-9]" $log | wc -l`
TEST[8]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13 \+ $CRIT14 \+ $CRIT15 \+ $CRIT16 \+ $CRIT17 \+ $CRIT18`
CTRL[8]=18
ERROR[8]="INITIAL HESSIAN NOT CORRECT"

# Initial step
CRIT1=`$GREP "N * (\-0|\-)\.00049....[0-9] * (0| )\.00000....[0-9] * (\-0|\-)\.00941....[0-9]" $log | wc -l`
CRIT2=`$GREP "H * (0| )\.06177....[0-9] * (\-0|\-)\.00000....[0-9] * (0| )\.15981....[0-9]" $log | wc -l`
CRIT3=`$GREP "H * (\-0|\-)\.0181(6|7)....[0-9] * (0| )\.04621....[0-9] * (0| )\.16397....[0-9]" $log | wc -l`
CRIT4=`$GREP "H * (\-0|\-)\.0181(6|7)....[0-9] * (\-0|\-)\.04621....[0-9] * (0| )\.16397....[0-9]" $log | wc -l`
TEST[9]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[9]=4
ERROR[9]="INITIAL STEP NOT CORRECT"

# Second energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.1938657(0|1)...[0-9]" $log | wc -l`
TEST[10]=`expr	$CRIT1`
CTRL[10]=1
ERROR[10]="SECOND ENERGY NOT CORRECT"

# Second gradient
CRIT1=`$GREP "N * (\-0|\-)\.000675...[0-9] * (0| )\.000000...[0-9] * (\-0|\-)\.01295...[0-9]" $log | wc -l`
CRIT2=`$GREP "H * (0| )\.0052(29|30)...[0-9] * (\-0|\-)\.000000...[0-9] * (0| )\.00405(5|6)...[0-9]" $log | wc -l`
CRIT3=`$GREP "H * (\-0|\-)\.00227(7|8)...[0-9] * (0| )\.004340...[0-9] * (0| )\.004447...[0-9]" $log | wc -l`
CRIT4=`$GREP "H * (\-0|\-)\.00227(7|8)...[0-9] * (\-0|\-)\.0043(39|40)...[0-9] * (0| )\.004447...[0-9]" $log | wc -l`
TEST[11]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[11]=4
ERROR[11]="SECOND GRADIENT NOT CORRECT"

# Second Hessian
CRIT1=`$GREP "N * x * (0| )\.81294[0-9]" $log | wc -l`
CRIT2=`$GREP "N * y * (\-0|\-|0| )\.00000[0-9] * (0| )\.814(79|80)[0-9]" $log | wc -l`
CRIT3=`$GREP "N * z * (\-0|\-)\.03560[0-9] * (\-0|\-|0| )\.00000[0-9] * (0| )\.13204[0-9]" $log | wc -l`
CRIT4=`$GREP "H * x * (\-0|\-)\.44878[0-9] * (\-0|\-|0| )\.00000[0-9] * (0| )\.12893[0-9] * (0| )\.4765(3|4)[0-9]" $log | wc -l`
CRIT5=`$GREP "H * y * (\-0|\-|0| )\.00000[0-9] * (\-0|\-)\.07941[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.00000[0-9] * (0| )\.07050[0-9]" $log | wc -l`
CRIT6=`$GREP "H * z * (0| )\.17998[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.05840[0-9] * (\-0|\-)\.14765[0-9] * (\-0|\-|0| )\.000000 * (0| )\.06057[0-9]" $log | wc -l`
CRIT7=`$GREP "H * x * (\-0|\-)\.18208[0-9] * (0| )\.1733(7|8)[0-9] * (\-0|\-)\.04666[0-9] * (\-0|\-)\.0138(7|8)[0-9] * (0| )\.03574[0-9] * (\-0|\-)\.01616[0-9]" $log | wc -l`
CRIT8=`$GREP "H * y * (0| )\.17107[0-9] * (\-0|\-)\.36769[0-9] * (0| )\.08456[0-9] * (\-0|\-)\.00544[0-9] * (0| )\.00445[0-9] * (0| )\.00064[0-9]" $log | wc -l`
CRIT9=`$GREP "H * z * (\-0|\-)\.07219[0-9] * (0| )\.12871[0-9] * (\-0|\-)\.03682[0-9] * (0| )\.00936[0-9] * (\-0|\-)\.01626[0-9] * (\-0|\-)\.00108[0-9]" $log | wc -l`
CRIT10=`$GREP "H * x * (\-0|\-)\.18208[0-9] * (\-0|\-)\.17337[0-9] * (\-0|\-)\.04666[0-9] * (\-0|\-)\.01388[0-9] * (\-0|\-)\.03574[0-9] * (\-0|\-)\.01616[0-9]" $log | wc -l`
CRIT11=`$GREP "H * y * (\-0|\-)\.17107[0-9] * (\-0|\-)\.36769[0-9] * (\-0|\-)\.08456[0-9] * (0| )\.00544[0-9] * (0| )\.00445[0-9] * (\-0|\-)\.00064[0-9]" $log | wc -l`
CRIT12=`$GREP "H * z * (\-0|\-)\.07219[0-9] * (\-0|\-)\.12871[0-9] * (\-0|\-)\.03682[0-9] * (0| )\.00936[0-9] * (0| )\.01626[0-9] * (\-0|\-)\.00108[0-9]" $log | wc -l`
CRIT13=`$GREP "H * x * (0| )\.18173[0-9]" $log | wc -l`
CRIT14=`$GREP "H * y * (\-0|\-)\.18738[0-9] * (0| )\.38570[0-9]" $log | wc -l`
CRIT15=`$GREP "H * z * (0| )\.05555[0-9] * (\-0|\-)\.09882[0-9] * (0| )\.04018[0-9]" $log | wc -l`
CRIT16=`$GREP "H * x * (0| )\.01422[0-9] * (0| )\.02174[0-9] * (0| )\.00727[0-9] * (0| )\.18173[0-9]" $log | wc -l`
CRIT17=`$GREP "H * y * (\-0|\-)\.02174[0-9] * (\-0|\-)\.02246[0-9] * (\-0|\-)\.01362[0-9] * (0| )\.18738[0-9] * (0| )\.38570[0-9]" $log | wc -l`
CRIT18=`$GREP "H * z * (0| )\.00727[0-9] * (0| )\.01362[0-9] * (\-0|\-)\.00227[0-9] * (0| )\.05555[0-9] * (0| )\.09882[0-9] * (0| )\.04018[0-9]" $log | wc -l`
TEST[12]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13 \+ $CRIT14 \+ $CRIT15 \+ $CRIT16 \+ $CRIT17 \+ $CRIT18`
CTRL[12]=18
ERROR[12]="SECOND HESSIAN NOT CORRECT"

# Third energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.19109492...." $log | wc -l`
TEST[13]=`expr	$CRIT1`
CTRL[13]=1
ERROR[13]="THIRD ENERGY NOT CORRECT"

# Final energy
CRIT1=`$GREP "\@ * Energy at current point\: * \-56\.186762439[0-9]" $log | wc -l`
TEST[14]=`expr	$CRIT1`
CTRL[14]=1
ERROR[14]="FINAL ENERGY NOT CORRECT"

# Convergence
CRIT1=`$GREP "\@ * Geometry optimization has converged\." $log | wc -l`
TEST[15]=`expr	$CRIT1`
CTRL[15]=1
ERROR[15]="GEOMETRY OPTIMIZATION NOT CONVERGED"

# Final gradient and Hessian eigenvalues
CRIT1=`$GREP "\@ * 1 * 1 * (\-0|\-|0| )\.000000.... * \-0*\.02836....." $log | wc -l`
CRIT2=`$GREP "\@ * 1 * 2 * (\-0|\-|0| )\.000000.... * 0*\.10603....." $log | wc -l`
CRIT3=`$GREP "\@ * 1 * 3 * (\-0|\-|0| )\.000000.... * 0*\.10603....." $log | wc -l`
CRIT4=`$GREP "\@ * 1 * 4 * (\-0|\-|0| )\.000000.... * 0*\.5581(6|7)....." $log | wc -l`
CRIT5=`$GREP "\@ * 1 * 5 * (\-0|\-|0| )\.000000.... * 0*\.59475....." $log | wc -l`
CRIT6=`$GREP "\@ * 1 * 6 * (\-0|\-|0| )\.000000.... * 0*\.59475....." $log | wc -l`
TEST[16]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[16]=6
ERROR[16]="FINAL GRADIENT AND HESSIAN EIGENVALUES NOT CORRECT"

# Final geometry
CRIT1=`$GREP "N * \-0*\.24216..... * (\-0|\-|0| )\.000000.... * 0*\.47713....." $log | wc -l`
CRIT2=`$GREP "H *    1\.61959..... * (\-0|\-|0| )\.000000.... * 0*\.38005....." $log | wc -l`
CRIT3=`$GREP "H *  \-1\.17305..... *   1\.614526.... * 0*\.52567....." $log | wc -l`
CRIT4=`$GREP "H *  \-1\.17305..... * \-1\.614527.... * 0*\.52567....." $log | wc -l`
TEST[17]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[17]=4
ERROR[17]="FINAL GEOMETRY NOT CORRECT"

# Final analysis
CRIT1=`$GREP "Vibrational analysis" $log | wc -l`
CRIT2=`$GREP "Cioslowski population analysis and static polarizabilities only\." $log | wc -l`
TEST[18]=`expr	$CRIT1 \+ $CRIT2`
CTRL[18]=2
ERROR[18]="FINAL ANALYSIS NOT SET UP CORRECTLY"

# Dipole moment gradient
 CRIT1=`$GREP "N * x * \-0*\.46729... * (\-0|\-|0| )\.00000... * \-0*\.03917..." $log | wc -l`
 CRIT2=`$GREP "N * y * (\-0|\-|0| )\.00000... * \-0*\.46525... * (\-0|\-|0| )\.00000..." $log | wc -l`
 CRIT3=`$GREP "N * z * \-0*\.03917... * (\-0|\-|0| )\.00000... * \-1\.21646..." $log | wc -l`
 CRIT4=`$GREP "H * x * 0*\.15209... * (\-0|\-|0| )\.00000... * 0*\.013248.." $log | wc -l`
 CRIT5=`$GREP "H * y * (\-0|\-|0| )\.00000... * 0*\.15876... * (\-0|\-|0| )\.00000..." $log | wc -l`
 CRIT6=`$GREP "H * z * 0*\.01324... * (\-0|\-|0| )\.00000... * 0*\.40547..." $log | wc -l`
 CRIT7=`$GREP "H * x * 0*\.15759... * 0*\.00318... * 0*\.01296..." $log | wc -l`
 CRIT8=`$GREP "H * y * 0*\.00318... * 0*\.15324... * \-0*\.00016..." $log | wc -l`
 CRIT9=`$GREP "H * z * 0*\.01296... * \-0*\.00016... * 0*\.40549..." $log | wc -l`
CRIT10=`$GREP "H * x * 0*\.15759... * \-0*\.0031(7|8)... * 0*\.01296..." $log | wc -l`
CRIT11=`$GREP "H * y * \-0*\.00318... * 0*\.15324... * 0*\.00016..." $log | wc -l`
CRIT12=`$GREP "H * z * 0*\.01296... * 0*\.00016... * 0*\.40549..." $log | wc -l`
TEST[19]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12`
CTRL[19]=12
ERROR[19]="DIPOLE MOMENT GRADIENT NOT CORRECT"

# Cioslowski charges
CRIT1=`$GREP "N * (\-0|\-)\.71633[0-9]" $log | wc -l`
CRIT2=`$GREP "H * (0| )\.23878[0-9]" $log | wc -l`
TEST[20]=`expr	$CRIT1 \+ $CRIT2`
CTRL[20]=2
ERROR[20]="CIOSLOWSKI CHARGES NOT CORRECT"

# Static polarizabilities
CRIT1=`$GREP "Ex * 8\.46776[0-9] * (0| |\-0|\-)\.000000 * (\-0|\-)\.2259(6|7)[0-9]" $log | wc -l`
CRIT2=`$GREP "Ey * (0| |\-0|\-)\.000000 * 8\.47954[0-9] * (0| |\-0|\-)\.00000[0-9]" $log | wc -l`
CRIT3=`$GREP "Ez * (\-0|\-)\.2259(6|7)[0-9] * (0| |\-0|\-)\.00000. * 4\.14607[0-9]" $log | wc -l`
TEST[21]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[21]=3
ERROR[21]="STATIC POLARIZABILITIES NOT CORRECT"

# Rotational constants
CRIT1=`$GREP "34348[56]\..... * 343485\..... * 171742\..... MHz" $log | wc -l`
CRIT2=`$GREP "11\.4574.. * 11\.4574.. * 5\.7287.. cm\-1" $log | wc -l`
TEST[22]=`expr	$CRIT1 \+ $CRIT2`
CTRL[22]=2
ERROR[22]="ROTATIONAL CONSTANTS NOT CORRECT"

# Vibrational frequencies
CRIT1=`$GREP "1 * A * 4065\.8[0-9] * (0| )\.01852[0-9] * 43\.34[0-9] * 1\.025[0-9]" $log | wc -l`
CRIT2=`$GREP "2 * A * 4065\.8[0-9] * (0| )\.01852[0-9] * 43\.34[0-9] * 1\.025[0-9]" $log | wc -l`
CRIT3=`$GREP "3 * A * 3840\.(4|5)[0-9] * (0| )\.01749[0-9] * (0| )\.00[0-9] * (0| )\.000[0-9]" $log | wc -l`
CRIT4=`$GREP "4 * A * 1714\.3[0-9] * (0| )\.00781[0-9] * 41\.55[0-9] * (0| )\.983[0-9]" $log | wc -l`
CRIT5=`$GREP "5 * A * 1714\.3[0-9] * (0| )\.00781[0-9] * 41\.55[0-9] * (0| )\.983[0-9]" $log | wc -l`
CRIT6=`$GREP "6 * A * 909\.3[0-9]i * (0| )\.00414[0-9]i" $log | wc -l`
TEST[23]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[23]=6
ERROR[23]="VIBRATIONAL FREQUENCIES NOT CORRECT"

# Partition function
CRIT1=`$GREP " 50\.00 * 3\.180[0-9](D|E)\+04 *  13\.9[0-9] * 1\.0000 * 4\.4424..(D|E)\+05" $log | wc -l`
CRIT2=`$GREP "100\.00 * 1\.799[0-9](D|E)\+05 *  38\.4[0-9] * 1\.0000 * 6\.9228..(D|E)\+06" $log | wc -l`
CRIT3=`$GREP "200\.00 * 1\.017[0-9](D|E)\+06 * 107\.3[0-9] * 1\.000. * 1\.0928..(D|E)\+08" $log | wc -l`
CRIT4=`$GREP "273\.15 * 2\.218[0-9](D|E)\+06 * 170\.7[0-9] * 1\.000. * 3\.7894..(D|E)\+08" $log | wc -l`
CRIT5=`$GREP "298\.15 * 2\.761[0-9](D|E)\+06 * 194\.5[0-9] * 1\.000. * 5\.3760..(D|E)\+08" $log | wc -l`
CRIT6=`$GREP "300\.00 * 2\.804[0-9](D|E)\+06 * 196\.3[0-9] * 1\.000. * 5\.5105..(D|E)\+08" $log | wc -l`
CRIT7=`$GREP "800\.00 * 3\.256[0-9](D|E)\+07 * 850\.3[0-9] * 1\.100. * 3\.0486..(D|E)\+10" $log | wc -l`
CRIT8=`$GREP "1500\.00 * 1\.567[0-9](D|E)\+08 * 2179\.6.   * 1\.641. * 5\.6091..(D|E)\+11" $log | wc -l`
TEST[24]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8`
CTRL[24]=8
ERROR[24]="MOLECULAR PARTITION FUNCTION NOT CORRECT"

PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi

%EOF%
#######################################################################
